﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.Http;

namespace ConsoleWebApi
{
    /// <summary>
    /// 测试webapi
    /// </summary>
    [Authorization.RequestAuthorize(Private_Key ="123456788990")]
    public class TestController : ApiController
    {
        // GET api/<controller>
        public IEnumerable<string> Get()
        {
            return new string[] { "value1", "value2" };
        }

        // GET api/<controller>/5
        public Demo Get(int id)
        {
            return  new Demo() { url="www.baidu.com",appName = "baidu" };
        }

        // POST api/<controller>
        public void Post([FromBody]Demo value)
        {
            Console.WriteLine(value.ToString());
        }

        // PUT api/<controller>/5
        public void Put(int id, [FromBody]string value)
        {
        }

        // DELETE api/<controller>/5
        public void Delete(int id)
        {
        }
    }
    public class Demo
    {
        public string appName { get; set; }
        public string url { get; set; }
        public override string ToString()
        {
            return string.Format("appName:{0},url:{1},datetime:{2}", this.appName, this.url, DateTime.Now);
        }
    }
}
